#include "../mtcp_module.h"


BMPF::BMPF()
{
	memset(&m_BMPF_REQ, 0, sizeof(m_BMPF_REQ));
	m_BMPF_REQ.HOT_SPOT_LOC_X = 123;
}


BMPF::~BMPF()
{
}


int BMPF::IMG_WIDTH(unsigned short v)
{
	m_BMPF_REQ.IMG_WIDTH = v;
	return 0;
}
int BMPF::IMG_HEIGHT(unsigned short v)
{
	m_BMPF_REQ.IMG_HEIGHT = v;
	return 0;
}
int BMPF::IMG_SIZE(unsigned short v)
{
	m_BMPF_REQ.IMG_SIZE = v;
	return 0;
}
int BMPF::NTC_STEADY_STATE(float v)
{
	m_BMPF_REQ.NTC_STEADY_STATE = v;
	return 0;
}
int BMPF::TOTAL_OPTICAL_POWER(float v)
{
	m_BMPF_REQ.TOTAL_OPTICAL_POWER = v;
	return 0;
}
int BMPF::BEAM_SIZE(float v)
{
	m_BMPF_REQ.BEAM_SIZE = v;
	return 0;
}
int BMPF::HOT_SPOT_POWER(float v)
{
	m_BMPF_REQ.HOT_SPOT_POWER = v;
	return 0;
}
int BMPF::HOT_SPOT_LOC_X(unsigned short v)
{
	m_BMPF_REQ.HOT_SPOT_LOC_X = v;
	return 0;
}
int BMPF::HOT_SPOT_LOC_Y(unsigned short v)
{
	m_BMPF_REQ.HOT_SPOT_LOC_Y = v;
	return 0;
}
int BMPF::I_DR(float v)
{
	m_BMPF_REQ.I_DR = v;
	return 0;
}
int BMPF::V_FOR(float v)
{
	m_BMPF_REQ.V_FOR = v;
	return 0;
}

int BMPF::setvalue(char *what, char* value)
{
	if (0 == strcmp(what, "IMG_WIDTH")){
		IMG_WIDTH(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "IMG_HEIGHT")){
		IMG_HEIGHT(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "IMG_SIZE")){
		IMG_SIZE(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "NTC_STEADY_STATE")){
		NTC_STEADY_STATE(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "V_FORWARD")){
		TOTAL_OPTICAL_POWER(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "BEAM_SIZE")){
		BEAM_SIZE(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "HOT_SPOT_POWER")){
		HOT_SPOT_POWER(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "HOT_SPOT_LOC_X")){
		HOT_SPOT_LOC_X(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "HOT_SPOT_LOC_Y")){
		HOT_SPOT_LOC_Y(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "I_DR")){
		I_DR(atof(value));
		return 0;
	}
	if (0 == strcmp(what, "V_FOR")){
		V_FOR(atof(value));
		return 0;
	}

	return -1;
}

int BMPF::SendBMPF()
{
	int ret = SendFrame(kMTCP_CTRL_BMPF, &m_BMPF_REQ, sizeof(m_BMPF_REQ), nullptr,0);
	tMTCP_payload_TEST_RSP rep;
	int recv_cnt = RecvResponse(&rep, sizeof(rep));
	return ret;
	return 0;
}